package longrise.phone.com.bjjt_henan.compensate;

import android.content.Context;
import android.view.View;
import android.widget.LinearLayout;
import android.widget.RelativeLayout;
import android.widget.TextView;

import com.longrise.android.FormParameter;
import com.longrise.android.FrameworkManager;
import com.longrise.android.LFView;
import com.longrise.bjjt.BaseApplication;

import longrise.phone.com.bjjt_henan.R;

/**
 * Created by Administrator on 2016/6/27.
 */
public class ChooseAccidentTypeView extends LFView implements View.OnClickListener {
    private Context context = null;
    private View view = null;
    private BaseApplication mApplication;
    private TextView tv_title;
    private String appCaseno;
    private LinearLayout hn_btn_back;
    private RelativeLayout ll_singleaccident;
    private RelativeLayout ll_doubleaccident;

    public ChooseAccidentTypeView(Context c, String appCaseNo) {
        super(c);
        this.context = c;
        this.mApplication = (BaseApplication) c.getApplicationContext();
        this.appCaseno = appCaseNo;
    }

    @Override
    public void refreshByTime() {

    }

    @Override
    public FormParameter getFormParameter() {
        FormParameter fp = new FormParameter();
        fp.setShowtitle(false);
        return fp;
    }

    @Override
    public void refresh() {

    }

    @Override
    public View getView() {
        return view;
    }

    @Override
    public void init() {
        initView();
        regEvent(true);
    }

    private void initView() {
        view = View.inflate(context, R.layout.chooseaccidenttype, null);
        hn_btn_back = (LinearLayout) view.findViewById(R.id.hn_btn_back);
        ll_singleaccident = (RelativeLayout) view.findViewById(R.id.ll_singleaccident);
        ll_doubleaccident = (RelativeLayout) view.findViewById(R.id.ll_doubleaccident);
        tv_title = (TextView) view.findViewById(R.id.tv_title);
        tv_title.setText("拍照挪车");
    }

    private void regEvent(boolean b) {
        if (null != hn_btn_back) {
            hn_btn_back.setOnClickListener(b ? this : null);
        }
        if (null != ll_singleaccident) {
            ll_singleaccident.setOnClickListener(b ? this : null);
        }
        if (null != ll_doubleaccident) {
            ll_doubleaccident.setOnClickListener(b ? this : null);
        }
    }

    @Override
    public void onClick(View v) {
        switch (v.getId()) {
            case R.id.hn_btn_back:
                closeForm();
                OnDestroy();
                break;
            case R.id.ll_singleaccident:
                //进入单车事故
                NewAccidentLoadPicView sView = new NewAccidentLoadPicView(context, appCaseno, 0);
                sView.setCaseType("0");
                FrameworkManager.getInstance().showNewForm(context, sView);
                break;
            case R.id.ll_doubleaccident:
                //进入双车事故
                NewAccidentLoadPicView dView = new NewAccidentLoadPicView(context, appCaseno, 0);
                dView.setCaseType("1");
                FrameworkManager.getInstance().showNewForm(context, dView);
                break;
        }
    }
}
